package com.zhijiaoyun.dao;

import com.zhijiaoyun.dao.core.IBaseDao;
import com.zhijiaoyun.model.Course;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author shisfish
 * @date 2017/6/6
 */
public interface ICourseDao extends IBaseDao<Course> {
    /**
     * get id with blobs
     *
     * @param courseId
     * @return
     */
    Course selectByPrimaryKeyBlobs(Long courseId);

    /**
     * get by name
     *
     * @param name
     * @return
     */
    Course selectByName(String name);

    /**
     * get by name not id
     *
     * @param courseId
     * @param name
     * @return
     */
    Course selectByNameNotCourseId(@Param("courseId") long courseId, @Param("name") String name);

    /**
     * count by params
     *
     * @param name
     * @param title
     * @param status
     * @param ids
     * @return
     */
    int countByParams(@Param("name") String name, @Param("title") String title, @Param("status") Integer status, @Param("ids") List<Long> ids);

    /**
     * page by params
     *
     * @param beginIndex
     * @param pageSize
     * @param name
     * @param title
     * @param status
     * @param ids
     * @return
     */
    List<Course> pageByParams(@Param("beginIndex") int beginIndex, @Param("pageSize") int pageSize,
                              @Param("name") String name, @Param("title") String title, @Param("status") Integer status, @Param("ids") List<Long> ids);

    /**
     * change lesson num
     *
     * @param courseId
     */
    void changeLessonNum(long courseId);

    /**
     * list by ids
     *
     * @param ids
     * @return
     */
    List<Course> selectCourseByIds(List<Long> ids);

    /**
     * get name by id
     *
     * @param courseId
     * @return
     */
    String selectCourseNameByCourseId(Long courseId);

    /**
     * add sale num
     *
     * @param courseId
     */
    void addSaleNum(Long courseId);

    /**
     * add view num
     *
     * @param courseId
     */
    void addViewNum(Long courseId);

    /**
     * count all
     *
     * @return
     */
    int countAll();

    /**
     * count history by params
     *
     * @param userId
     * @param name
     * @param ids
     * @return
     */
    int countCourseHistoryByParams(@Param("userId") long userId, @Param("name") String name, @Param("ids") List<Long> ids);

    /**
     * page history by params
     *
     * @param beginIndex
     * @param pageSize
     * @param userId
     * @param name
     * @param ids
     * @return
     */
    List<Course> pageCourseHistoryByParams(@Param("beginIndex") int beginIndex, @Param("pageSize") int pageSize, @Param("userId") long userId,
                                           @Param("name") String name, @Param("ids") List<Long> ids);


}